package Reflected;

class Student {
	private String name="bit";
	public int age=18;

	public Student() {
		System.out.println("这是学生类");
	}
	private Student(String name,int age) {
		this.name=name;
		this.age=age;
		System.out.println("Student ( String name)");
	}
	private void eat() {
		System.out.println("我正在吃东西");
	}
	public void sleep() {
		System.out.println("我正在睡觉");
	}
	private void function(String str) {
		System.out.println(str);
	}

	@Override
	public String toString() {
		return "Student{" +
				"name='" + name + '\'' +
				", age=" + age +
				'}';
	}
}
public class Test {
	public static void main(String[] args) throws ClassNotFoundException{
		Class<?> c1;
		//获取class类的第一种办法
		c1=Class. forName("Reflected.Student");
		//这个异常也可以直接交给虚拟机在处理，如果上层调用者不处理的话
		Class <?> c2=Student.class;
		Student student=new Student();
		Class<?> c3=student.getClass();//第二种办法


		Class<?> c4=Student.class;//第三种办法

		System.out.println(c1.equals(c2));
		System.out.println(c1.equals(c3));
		System.out.println(c3.equals(c2));
	}
}
